package com.ruoyi.media.forestApi;

import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;

import java.util.Map;

/**
 * 视频号所有请求
 */
@BaseRequest(
        baseURL = "https://channels.weixin.qq.com", // 默认域名
        headers = {
                "origin: https://channels.weixin.qq.com",
                "referer: https://channels.weixin.qq.com/",// 默认请求头
                "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36"
        }
)
public interface ChannelsApi {


    /**
     * 获取上传的参数数据
     * @param sessionId
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/helper/helper_upload_params",headers = {
            "Cookie:${sessionId}",
            "Content-Type:application/json"
     })
     String  queryChannelsAuthKey(@JSONBody Map<String,Object> params, @Var("sessionId")String sessionId);


    /**
     * 获取账号权限
     * @param params
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/auth/auth_110_report",headers = {
            "Cookie:${sessionId}",
            "Content-Type:application/json",
            "Host:channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com"
    })
    String auth_110_report(@JSONBody Map<String,Object> params);


    /**
     * 获取视频号分片上传的UploadID
     * @reture
     */
    @Put(url = "https://finder-assistant.mp.video.tencent-cloud.com/applyuploaddfs",headers = {
            "authorization: ${authorization}",
            "content-length: 60",
            "content-type: application/json",
            "x-arguments: ${arguments}"
    })
    String queryUploadID(@JSONBody JSONObject body, @Var("arguments")String arguments, @Var("authorization")String authorization);


    /**
     * 登录到该视频号获取rawKeyBuff
     * @param params
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/auth/auth_set_finder",
    headers = {
            "Content-Type: application/json",
            "Cookie:${cookies}",
            "Host:channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: 0000000000"
    })
    String authSetFinder(@JSONBody Map<String, Object> params,@Var("cookies")String cookies);


    /**
     * 根据cookies参数获取数据
     * @param cookie
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/auth/auth_data",headers = {
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: 0000000000",
            "Content-Type: application/json",
            "Cookie: ${cookie}"
    })
    String queryAuthData(@Query Map<String, Object> params, @Var("cookie")String cookie);



    /**
     * 获取视频号已发文的的数据
     * @param sessionId
     * @param uin
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/post/post_list",headers = {
            "Cookie:${sessionId}",
            "Content-Type:application/json",
            "Host: channels.weixin.qq.com",
            "X-WECHAT-UIN: ${uin}",
            "Referer: https://channels.weixin.qq.com/platform/login"
    })
    String queryChannelsData(@Var("sessionId")String sessionId,@Var("uin")String uin,@JSONBody Map<String,Object> params);


    /**
     * 上传视频
     * @return
     */
    @Put(url = "https://finder-assistant.mp.video.tencent-cloud.com/uploadpartdfs",headers = {
            "authorization: ${authorization}",
            "content-length: ${contentLength}",
            "content-type: application/octet-stream",
            "x-arguments: ${arguments}"
    })
    ForestResponse uploadVideo(@Query Map<String,Object> params, @Body byte[] bytes, @Var("authorization")String authorization,
                               @Var("contentLength")Integer contentLength, @Var("arguments")String arguments);

//    /**
//     * 上传视频封面
//     * @return
//     */
//    @Put(url = "https://finder-assistant.mp.video.tencent-cloud.com/uploadpartdfs",headers = {
//            "authorization: ${authorization}",
//            "content-length: ${contentLength}",
//            "content-type: application/octet-stream",
//            "x-arguments: ${arguments}"
//    })
//    ForestResponse uploadVideoImage(@Query Map<String,Object> params, @Body InputStream inputStream, @Var("authorization")String authorization,
//                                    @Var("contentLength")int contentLength, @Var("arguments")String arguments);





    /**
     * 视频完成部分上传
     * @return
     */
    @Post(value = "https://finder-assistant.mp.video.tencent-cloud.com/completepartuploaddfs",headers = {
            "accept: application/json, text/plain, */*",
            "accept-encoding: gzip, deflate, br",
            "accept-language: zh-CN,zh;q=0.9",
            "authorization: ${authorization}",
            "content-type: application/json",
            "origin: https://channels.weixin.qq.com",
            "referer: https://channels.weixin.qq.com/",
            "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36",
            "x-arguments: ${arguments}",
            "content-md5: null",
            "content-length: ${length}"
    })
    String completepartuploaddfs(@Query Map<String,Object> params, @JSONBody Map<String,Object> jsonObject,@Var("authorization")String authorization,
                                 @Var("length")int length,@Var("arguments")String arguments);


//    /**
//     * 视频发布
//     * @param cookies
//     * @param uin
//     * @param channelsPublishParams
//     * @return
//     */
//    @Post(value = "/cgi-bin/mmfinderassistant-bin/post/post_create",headers = {
//            "Content-Type: application/json",
//            "Connection: keep-alive",
//            "Cookie:${cookies}",
//            "Host: channels.weixin.qq.com",
//            "Origin: https://channels.weixin.qq.com",
//            "Referer: https://channels.weixin.qq.com/platform/login",
//            "X-WECHAT-UIN: ${uin}"
//    })
//    String postCreate(@Var("cookies")String cookies,@Var("uin")String uin,@JSONBody ChannelsPublishParams channelsPublishParams);



    /**
     * 视频号获取标题数据
     * @param cookies
     * @param uin
     * @param params
     * @return
     */
    @Post(value = "/cgi-bin/mmfinderassistant-bin/helper/helper_parse_mp_link",headers = {
            "Content-Type: application/json",
            "Connection: keep-alive",
            "Cookie:${cookies}",
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: ${uin}"
    })
    String helperParseMpLink(@Var("cookies")String cookies,@Var("uin")String uin,@JSONBody Map<String,Object> params);




    /**
     * 根据参数获取信息
     * @param params
     * @param uuid
     * @return
     */
    @Post(url = "https://gateway.qschou.com/v3.0.0/project/index/data",
            headers = {
            "Host: gateway.qschou.com",
            "Content-Type: application/json; charset=UTF-8",
            "Origin: https://m2.qschou.com",
            "Platform: qsc_h5",
            "Referer: https://m2.qschou.com/fund/detail2?projuuid=${uuid}",
            "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36"
    })
    String gatewayQsChou(@JSONBody JSONObject params,@Var("uuid")String uuid);


    /**
     * 获取水滴筹参数
     * @param params
     * @return
     */
    @Post(url = "https://api.shuidichou.com/api/cf/v4/get-funding-info",
    headers = {
            "referer: https://www.shuidichou.com/",
            "content-type: application/x-www-form-urlencoded",
            "platform: 2"
    })
    String getshuidichou(@Query Map<String, Object> params);


    /**
     * 根据视频主键删除视频
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/post/post_delete",headers = {
            "Content-Type: application/json",
            "Cookie: ${cookies}",
            "Connection: keep-alive",
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: ${uin}"
    })
    String deleteBatch(@Var("uin")String uin,@Var("cookies")String cookies,@JSONBody Map<String,Object> params);


    /**
     * 查询可绑定的运营账号
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/member/member_query_invite_user",headers = {
            "Content-Type: application/json",
            "Cookie: ${cookies}",
            "Connection: keep-alive",
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: ${uin}"
    })
    String queryUserMessage(@Var("uin")String uin,@Var("cookies")String cookies,@JSONBody Map<String,Object> params);


    /**
     * 发送绑定邀请
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/member/member_invite",headers = {
            "Content-Type: application/json",
            "Cookie: ${cookies}",
            "Connection: keep-alive",
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: ${uin}"
    })
    String memberOperation(@Var("uin")String uin,@Var("cookies")String cookies,@JSONBody Map<String,Object> params);


    /**
     * 根据视频链接获取唯一id
     * @param cookie
     * @param uin
     * @param params
     * @return
     */
    @Post(url = "/cgi-bin/mmfinderassistant-bin/post/post_clip_video",headers = {
            "Content-Type: application/json",
            "Cookie:${cookie}",
            "Connection: keep-alive",
            "Host: channels.weixin.qq.com",
            "Origin: https://channels.weixin.qq.com",
            "Referer: https://channels.weixin.qq.com/platform/login",
            "X-WECHAT-UIN: ${uin}"
    })
    String postClipVideo(@Var("cookie")String cookie,@Var("uin")String uin,@JSONBody Map<String,Object> params);


    /**
     * 获取快代理专享的ip
     * @return
     */
    @Get(url = "https://tps.kdlapi.com/api/gettps?secret_id=${secretId}&num=1&signature=${signature}")
    String getKdl(@Var("secretId") String secretId,@Var("signature") String signature);


    @Backend("httpclient")
    @HTTPProxy(host = "${ip}", port = "${port}")
    @Post(url = "http://nimings.top/index.php/start-page.html/comment")
    ForestResponse gogogo(@Var("ip")String ip,@Var("port")String port,@JSONBody Map<String,Object> params);

}
